package com.qf.controller;

import com.qf.pojo.SWanInfo;
import com.qf.service.SWanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class SWanInfoController {
    @Autowired
    SWanInfoService sWanInfoService;
    @RequestMapping("/findSWanInfoAll")
    public List<SWanInfo> findAll(){
        return sWanInfoService.findAll();
    }
    @RequestMapping("/findSWanInfoById")
    public SWanInfo findById(@RequestBody Map map){
        String id=(String)map.get("id");
        return sWanInfoService.findById(Integer.valueOf(id));

    }
    @RequestMapping("/deleteSWanInfoById")
    public String deleteById(@RequestBody Map map){
        try {
            Integer id=(Integer)map.get("id");
            sWanInfoService.deleteById(id);
        }catch (Exception e){
            return "fail";
        }
        return "success";
    }
    @RequestMapping("/saveAndUpdateSWanInfo")
    public String saveAndUpdate(@RequestBody SWanInfo sWanInfo){
        try {
            sWanInfoService.saveAndUpdate(sWanInfo);
        }catch (Exception e){
            return "fail";
        }
        return "success";
    }
    @RequestMapping("/findSWanInfoBySSexAndSCountry")
    public List<SWanInfo> findMusicBySSexAndSCountry(@RequestBody Map map){
        Integer ssex=(Integer) map.get("ssex");
        String scountry=(String)map.get("scountry");
        return  sWanInfoService.findMusicBySSexAndSCountry(ssex,scountry);
    }
    @RequestMapping("/findSWanInfoBySTypeAndSCountry")
    public List<SWanInfo> findSWanInfoBySTypeAndSCountry(@RequestBody Map map){
        Integer stype=(Integer)map.get("stype");
        String scountry=(String)map.get("scountry");
        return  sWanInfoService.findMusicBySTypeAndSCountry(stype,scountry);
    }
}
